package world.controllers

import org.apache.shiro.authz.AuthorizationException
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.ResponseStatus

@ControllerAdvice
class ExceptionController { //全局异常处理

    @ExceptionHandler(AuthorizationException.class)
    @ResponseStatus(HttpStatus.FORBIDDEN)
    @ResponseBody
    String handleAuthorizationException(AuthorizationException e) { //AuthorizationException异常处理
        return "Error ${HttpStatus.FORBIDDEN.value()}：未授权"
    }

}
